package com.daogu.fuelcard.config;

import com.daogu.fuelcard.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/oil-manage/**")  // 指定拦截 "/oil-manage/" 下的所有请求
                .excludePathPatterns(
                        "/oil-manage/login",          // 排除登录页面
                        "/oil-manage/insertUser",     // 排除insertUser API
                        "/oil-manage/swagger-ui/**",  // 排除Swagger UI界面
                        "/oil-manage/v2/api-docs",    // 排除Swagger文档
                        "/oil-manage/swagger-resources/**", // 排除Swagger资源
                        "/oil-manage/webjars/**"      // 排除webjars资源
                );
    }

}